home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / WINSOCK.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  6KB  |  161 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1995, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.9  $
  6. //
  7. // Main header of the Winsock OWL subsystem.
  8. //----------------------------------------------------------------------------
  9. #if !defined(OWL_WINSOCK_H)
  10. #define OWL_WINSOCK_H
  11.  
  12. #if !defined(OWL_MODULE_H)
  13. # include <owl/module.h>
  14. #endif
  15. #if !defined (_WINSOCKAPI_)
  16. # include <winsock.h>
  17. #endif
  18. #if !defined(OWL_WSKADDR_H)
  19. # include <owl/wskaddr.h>
  20. #endif
  21. #if !defined(OWL_WSKSOCK_H)
  22. # include <owl/wsksock.h>
  23. #endif
  24. #if !defined(OWL_WSKERR_H)
  25. # include <owl/wskerr.h>
  26. #endif
  27. #if !defined(OWL_WSKHOSTM_H)
  28. # include <owl/wskhostm.h>
  29. #endif
  30. #if !defined(OWL_WSKSOCKD_H)
  31. # include <owl/wsksockd.h>
  32. #endif
  33. #if !defined(OWL_WSKSOCKM_H)
  34. # include <owl/wsksockm.h>
  35. #endif
  36. #if !defined(OWL_WSKSERVM_H)
  37. # include <owl/wskservm.h>
  38. #endif
  39.  
  40. #if defined(BI_NAMESPACE)
  41. namespace OWL {
  42. #endif
  43.  
  44. // Generic definitions/compiler options (eg. alignment) preceeding the 
  45. // definition of classes
  46. #include <services/preclass.h>
  47.  
  48. //
  49. // class TWinSockDll
  50. // ~~~~~ ~~~~~~~~~~~
  51. // Wrapper for the WinSock dll itself
  52. //
  53. class _OWLCLASS TWinSockDll : public TModule {
  54.   public:
  55.     TWinSockDll();
  56.  
  57.     // Socket functions
  58.     //
  59.     static SOCKET      accept(SOCKET s, struct sockaddr far* addr,
  60.                         int far* addrLen);
  61.     static int         bind(SOCKET s, struct sockaddr far* addr, int nameLen);
  62.     static int         closesocket(SOCKET s);
  63.     static int         connect(SOCKET s, struct sockaddr far* name, int nameLen);
  64.     static int         getpeername(SOCKET s, struct sockaddr far* name,
  65.                         int far* nameLen);
  66.     static int         getsockname(SOCKET s, struct sockaddr far* name,
  67.                         int far* nameLen);
  68.     static int         getsockopt(SOCKET s, int level, int optName, char far* optVal,
  69.                         int far* optLen);
  70.     static ulong       htonl(ulong hostLong);
  71.     static ushort      htons(ushort hostShort);
  72.     static ulong       inet_addr(const char far* cp);
  73.     static char far*   inet_ntoa(struct in_addr in);
  74.     static int         ioctlsocket(SOCKET s, long cmd, ulong far* argp);
  75.     static int         listen(SOCKET s, int backlog);
  76.     static ulong       ntohl(ulong netLong);
  77.     static ushort      ntohs(ushort netShort);
  78.     static int         recv(SOCKET s, char far* buf, int len, int flags);
  79.     static int         recvfrom(SOCKET s, char far* buf, int len, int flags,
  80.                         struct sockaddr far* from, int* fromLen);
  81.     static int         select(int nfds, struct fd_set far* readfds,
  82.                         struct fd_set far* writefds,
  83.                         struct fd_set far* exceptfds,
  84.                         const struct timeval far* timeout);
  85.     static int         send(SOCKET s, const char far* buf, int len, int flags);
  86.     static int         sendto(SOCKET s, const char far* buf, int len, int flags,
  87.                         const struct sockaddr far* to, int toLen);
  88.     static int         setsockopt(SOCKET s, int level, int optName,
  89.                         const char far* optVal, int optLen);
  90.     static int         shutdown(SOCKET s, int how);
  91.     static SOCKET      socket(int af, int type, int protocol);
  92.  
  93.     // Database functions
  94.     //
  95.     static struct hostent  far*  gethostbyaddr(const char far* addr, int len,
  96.                                   int type);
  97.     static struct hostent  far*  gethostbyname(const char far* name);
  98.     static int                   gethostname(char far* name, int nameLen);
  99.     static struct servent  far*  getservbyname(const char far* name,
  100.                                   const char far* proto);
  101.     static struct servent  far*  getservbyport(int port, const char far* proto);
  102.     static struct protoent far*  getprotobyname(const char far* name);
  103.     static struct protoent far*  getprotobynumber(int proto);
  104.  
  105.     // Microsoft Windows Extension functions
  106.     //
  107.     static int     WSAStartup(uint16 versionRequested, LPWSADATA WSAData);
  108.     static int     WSACleanup(void);
  109.     static void    WSASetLastError(int error);
  110.     static int     WSAGetLastError(void);
  111.     static BOOL    WSAIsBlocking(void);
  112.     static int     WSAUnhookBlockingHook(void);
  113.     static FARPROC WSASetBlockingHook(FARPROC blockFunc);
  114.     static int     WSACancelBlockingCall(void);
  115.     static HANDLE  WSAAsyncGetServByName(HWND hWnd, uint msg,
  116.                     const char far* name, const char far* proto, char far* buf,
  117.                     int bufLen);
  118.     static HANDLE  WSAAsyncGetServByPort(HWND hWnd, uint msg, int port,
  119.                     const char far* proto, char far* buf, int bufLen);
  120.     static HANDLE  WSAAsyncGetProtoByName(HWND hWnd, uint msg,
  121.                     const char far* name, char far* buf, int bufLen);
  122.     static HANDLE  WSAAsyncGetProtoByNumber(HWND hWnd, uint msg, int number,
  123.                     char far* buf, int bufLen);
  124.     static HANDLE  WSAAsyncGetHostByName(HWND hWnd, uint msg,
  125.                     const char far* name, char far* buf, int bufLen);
  126.     static HANDLE  WSAAsyncGetHostByAddr(HWND hWnd, uint msg,
  127.                     const char far* addr, int len, int type, char far* buf,
  128.                     int bufLen);
  129.     static int     WSACancelAsyncRequest(HANDLE hTaskHandle);
  130.     static int     WSAAsyncSelect(SOCKET s, HWND hWnd, uint msg, long event);
  131.     static int     WSARecvEx(SOCKET s, char far* buf, int len, int far* flags);
  132.  
  133.     // Check for presence of Winsock DLL
  134.     //
  135.     static TModule& WinSockModule();
  136.     static bool IsAvailable();
  137. };
  138.  
  139. //
  140. // class TWinSock
  141. // ~~~~~ ~~~~~~~~
  142. // Loader for the WinSock dll
  143. //
  144.  
  145. class _OWLCLASS TWinSock
  146. {
  147.   public:
  148.     static bool         IsAvailable(void);
  149.     static TWinSockDll* Dll(void);
  150. };
  151.  
  152. // Generic definitions/compiler options (eg. alignment) following the 
  153. // definition of classes
  154. #include <services/posclass.h>
  155.  
  156. #if defined(BI_NAMESPACE)
  157. } // namespace OWL
  158. #endif
  159.  
  160. #endif  // OWL_WSKDLL_H
  161.